// CommandBarsList.cpp : Implementation of CCommandBarsList

#include "stdafx.h"
#include "CommandBarsList.h"
#include "CommandBars.h"

// CCommandBarsList
CCommandBarsList  *theCommandBarsList = NULL;


CCommandBarsList::CCommandBarsList():
	m_nQuery(0)
{
	theCommandBarsList = this;
}


STDMETHODIMP CCommandBarsList::InterfaceSupportsErrorInfo(REFIID riid)
{
	static const IID* arr[] = 
	{
		&IID_ICommandBarsList
	};

	for (int i=0; i < sizeof(arr) / sizeof(arr[0]); i++)
	{
		if (InlineIsEqualGUID(*arr[i], riid))
			return S_OK;
	}

	return S_FALSE;
}


STDMETHODIMP CCommandBarsList::QueryStateItems()
{
	_CommandBarsList::_ColType::const_iterator	iter = m_coll.begin();

	SAF_TRY;

	for (; (iter!=m_coll.end() && m_nQuery==0); iter++)
	{
#ifdef _DEBUG
		CString	strTitle;
		(*iter)->GetWindowText(strTitle);
		TraceDebug(_T("CCommandBarsList::QueryStateItems: %s\n"), (LPCTSTR)strTitle);
#endif
		(*iter)->QueryStateItems();
	}

	SAF_CATCH

	return S_OK;
}

//
//STDMETHODIMP CCommandBarsList::get_Item(VARIANT varItem, ICommandBars **ppCommandBars)
//{
//	return S_OK;
//}
//

STDMETHODIMP CCommandBarsList::LockQuery(void)
{
	m_nQuery++;

	return S_OK;
}


STDMETHODIMP CCommandBarsList::FreeQuery(void)
{
	m_nQuery--;

	return S_OK;
}
